package com.study.springsecurity.controller;

import com.alibaba.fastjson.JSON;
import com.study.springsecurity.pojo.Result;
import com.study.springsecurity.utils.SecurityContextUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Collection;

/**
 * 业务接口
 */
@Slf4j
@RestController
@RequestMapping("/business")
public class BusinessController {
    /**
     * 获取当前登录用户名称
     *
     * @return
     */
    @GetMapping("/getCurrentLoginUserName")
    public Result<String> getCurrentLoginUserName() {
        String userName = SecurityContextUtil.getUserName();
        return new Result<>(userName);
    }
}
